/**  
 * All rights Reserved, Designed By www.flksh.com
 * @date:   2017-11-24 13:49:32   
 * @Copyright: 2013-2017 www.flksh.com Inc. All rights reserved. 
 * 注意：本内容仅限于上海福乐康社区养老服务有限公司内部传阅，禁止外泄以及用于其他的商业目
 */
package com.zx.cloud.service;

import java.math.BigDecimal;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zx.cloud.common.auth0.jwt.impl.PublicClaims;
import com.zx.cloud.domain.Dict;
import com.zx.cloud.domain.Edition;
import com.zx.cloud.domain.LianLianParam;
import com.zx.cloud.persistence.CrudMapper;
import com.zx.cloud.persistence.DictMapper;
import com.zx.cloud.persistence.EditionMapper;

/**
 * app迭代管理
 */
@Service
public class EditionService extends CrudServiceImpl<Edition>{
    
    private static final Logger LOGGER = LoggerFactory.getLogger(EditionService.class);
    
    @Autowired
    private EditionMapper  editionMapper;
    
    @Autowired
	private DictMapper dictMapper;
    
  	@Autowired
    public EditionService(CrudMapper<Edition> mapper) {
        super(mapper);
    }

	public List<Edition> getAppVersion(Edition edition) {
		
		return editionMapper.getAppVersion(edition);
	}

   public  LianLianParam  getLianLianParam(){
	     LianLianParam   param=new LianLianParam();
	     Dict dict=new Dict();
		 dict.setParentCode("LL0001");
		 List<Dict> dicts=dictMapper.getDitByParentCode(dict);
		 for (int i = 0; i < dicts.size(); i++) {
			if("LL00001".equals(dicts.get(i).getCode())){
				param.setCompanyNum(dicts.get(i).getValue());
			}
			if("LL00002".equals(dicts.get(i).getCode())){
				param.setPublicKey(dicts.get(i).getValue());
			}
			if("LL00003".equals(dicts.get(i).getCode())){
				param.setPrivateKey(dicts.get(i).getValue());
			}
		}
	   return  param;
   }

public String getPaymentSwitch() {
	 Dict dict=new Dict();
	 dict.setParentCode("PC0001");
	 List<Dict> dicts=dictMapper.getDitByParentCode(dict);
	 if(dicts.size()>0){
		 return  dicts.get(0).getValue();
	 }else{
		 return  "1";
	 }
}
/**
 * @Description:
 */
public int switchPayment(int  type) {
	 Dict dict=new Dict();
	 dict.setParentCode("PC0001");
	 List<Dict> dicts=dictMapper.getDitByParentCode(dict);
	 if(dicts.size()>0 && type==0){
		 Dict newDict=new Dict();
		 newDict.setId(dicts.get(0).getId());
		 newDict.setName("开");
		 newDict.setValue("0");
	 }else if(dicts.size()>0 && type==1){
		 Dict newDict=new Dict();
		 newDict.setId(dicts.get(0).getId());
		 newDict.setName("关");
		 newDict.setValue("1");
	 }
	
	return 1;
}
}
